package com.example.controller;
import com.example.pojo.PageBeans;
import com.example.pojo.Result;
import com.example.service.FoodService;
import com.example.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
public class FoodController {

    //或者slf4j
 //   private static Logger log = LoggerFactory.getLogger(HotelController.class);

    @Autowired
    private FoodService foodService;
    @Autowired
    private OrderService orderService;
/*
分页查询--餐饮菜单
 */

 /*   @GetMapping("/food/select")
    public Result select(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5")Integer pageSize){//如果前端没有传递参数，也要设置默认值
       PageBeans pageBeans = foodService.select(page,pageSize);
       log.info("分页查询--餐饮菜单查询；{},{}",page,pageSize  );
        return Result.success(pageBeans);
    }*/
 @GetMapping("/foods/list")
 public Result list(@RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "5")Integer pageSize){//如果前端没有传递参数，也要设置默认值
     PageBeans pageBeans = foodService.list(page,pageSize);
     log.info("分页查询--餐饮菜单查询；{},{}",page,pageSize  );
     return Result.success(pageBeans);
 }

 /*
 预定餐饮
  */

    @PutMapping("/foods/preserve/{id}")
    public void preserve(@PathVariable int id,String name,int number,int price){
        foodService.preserve(id,number);
        orderService.insertHotel(name,number,price);
    }
}

